<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%
	String rootPath = request.getContextPath();
%>
<!DOCTYPE>
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<title>我的收货地址</title>
<meta name="viewport" content="initial-scale=1, maximum-scale=1" />
<meta name="apple-mobile-web-app-capable" content="yes" />
<meta name="apple-mobile-web-app-status-bar-style" content="black" />
<link rel="stylesheet" href="//g.alicdn.com/msui/sm/0.6.2/css/sm.min.css" />
<link rel="stylesheet" href="//g.alicdn.com/msui/sm/0.6.2/css/sm-extend.min.css" />
<link rel="stylesheet" href="../static/weixin.css" />
</head>
<body>
	<header class="bar bar-nav">
	  <h1 class="title">增加新地址</h1>
	</header>
	<form id="form1" method="post" >
		<div class="list-block">
		<input type="hidden" name="memberAddress.addressid" value="${memberAddress.addressid}">
		<input type="hidden" name="pagesrc" id="pagesrc" value="${pagesrc}">
			<ul>
				<li>
			        <div class="item-content">
			          <div class="item-media"><i class="icon icon-form-name"></i></div>
			          <div class="item-inner">
			            ${msg}
			          </div>
			        </div>
			      </li>
      
				<li>
					<div class="item-content">
						<div class="item-media">
							<i class="icon icon-form-name"></i>
						</div>
						<div class="item-inner">
							<div class="item-title label">收件人</div>
							<div class="item-input">
								<input type="text" id="username" placeholder="收件人" name="memberAddress.username" 
								value="${memberAddress.username}">
								
								
								<!-- <input type="text" class="form-control" id="input-msg-demo-required" 
								name='input-msg-demo-required' placeholder="rule" data-rule-required='true' 
								data-rule-email="true" data-msg-required="亲，邮箱是必填项哦" data-msg-email="亲，你的邮箱地址好像不对哦~"/> -->
								
							</div>
						</div>
					</div>
				</li>
				<li>
					<div class="item-content">
						<div class="item-media">
							<i class="icon icon-form-name"></i>
						</div>
						<div class="item-inner">
							<div class="item-title label">联系电话</div>
							<div class="item-input">
								<input type="text" placeholder="联系电话" id="phone" name="memberAddress.phone" value="${memberAddress.phone}">
							</div>
						</div>
					</div>
				</li>
				<li>
					<div class="item-content" >
						<div class="item-media">
							<i class="icon icon-form-name"></i>
						</div>
						<div class="item-inner">
							<div class="item-title label">所在地区</div>
							<div class="item-input" >
								<input type="text" id="citypicker" placeholder="所在地区" name="memberAddress.area" value="${memberAddress.area}">
							</div>
						</div>
					</div>
				</li>
				<li>
					<div class="item-content">
						<div class="item-media">
							<i class="icon icon-form-name"></i>
						</div>
						<div class="item-inner">
							<div class="item-title label">所在街道</div>
							<div class="item-input">
								<input type="text" placeholder="所在街道" id="street" name="memberAddress.street" value="${memberAddress.street}">
							</div>
						</div>
					</div>
				</li>
				<li class="align-top">
					<div class="item-content">
						<div class="item-media">
							<i class="icon icon-form-comment"></i>
						</div>
						<div class="item-inner">
							<div class="item-title label">详细地址</div>
							<div class="item-input">
								<textarea name="memberAddress.address">${memberAddress.address}</textarea>
							</div>
						</div>
					</div>
				</li>
			</ul>
		</div>
		
	<div class="content-block">
	
		<div class="row">
			<div class="col-50">
				<a href="javascript:void(0);" class="button button-big button-fill button-danger" onclick="doSave();">保存地址</a>
			</div>
			<div class="col-50">
				<a href="javascript:void(0);" class="button button-big button-fill button-success">读取微信地址</a>
			</div>
		</div>
		
		<p id="buyjump"><a href="javascript:void();" class="button button-big button-fill" onclick="doBuy();">返回购买</a></p>
		
	</div>	
</form>		
    <script type='text/javascript' src='//g.alicdn.com/sj/lib/zepto/zepto.min.js' charset='utf-8'></script>
    <script type='text/javascript' src='//g.alicdn.com/msui/sm/0.6.2/js/sm.min.js' charset='utf-8'></script>
    <script type='text/javascript' src='//g.alicdn.com/msui/sm/0.6.2/js/sm-extend.min.js' charset='utf-8'></script>
    <script type="text/javascript" src="//g.alicdn.com/msui/sm/0.6.2/js/sm-city-picker.min.js" charset="utf-8"></script>
	
	<script type="text/javascript">
		
	$(document).ready(function() {
		if($("#pagesrc").val()=='buy'){
			$("#buyjump").show();
		}
		else{
			$("#buyjump").hide();
		}
	});

	function doSave() {
		if(doValueValidate()){
			form1.action="<%=rootPath%>/weixin/memberaddsave";
			form1.submit();
		}
	}
	
	function doValueValidate()
	{
		var username = $("#username").val();
		if(username ==null || username ==''){
			  $.alert('请填写收货人');
			return false;
		}
		var phone = $("#phone").val();
		if(phone ==null || phone ==''){
			 $.alert('请填写收货人联系方式 ');
			return false;
		}
		var citypicker = $("#citypicker").val();
		if(citypicker ==null || citypicker ==''){
			$.alert('请填写所在省市 ');
			return false;
		}
		var street = $("#street").val();
		if(street ==null || street==''){
			$.alert('请填写地址 ');
			return false;
		}
		return true;
	} 
	
	function doBuy()
	{
		form1.action="<%=rootPath%>/weixin/choosegoods";
		form1.submit();
	}
    $("#citypicker").cityPicker({
    	    toolbarTemplate: '<header class="bar bar-nav">\
    	    <button class="button button-link pull-right close-picker">确定</button>\
    	    <h1 class="title">选择收货地址</h1>\
    	    </header>'
    	  });
	      
	</script>

</body>
</html>